package com.ruoyi.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.business.domain.ShopCard;
import com.ruoyi.business.vo.ShopCardVo;
import com.ruoyi.business.mapper.ShopCardMapper;
import com.ruoyi.business.service.IShopCardService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 卡卷Service业务层处理
 *
 * @author Tellsea
 * @date 2025-01-19
 */
@Service
public class ShopCardServiceImpl extends ServiceImpl<ShopCardMapper, ShopCard> implements IShopCardService {

    @Override
    public TableDataInfo<ShopCardVo> queryList(ShopCardVo entity) {
        return PageUtils.buildDataInfo(this.baseMapper.queryList(PageUtils.buildPage(), entity));
    }

    @Override
    public List<ShopCardVo> queryAll(ShopCardVo entity) {
        return this.baseMapper.queryList(entity);
    }

    @Override
    public ShopCardVo queryById(Long id) {
        return this.baseMapper.queryById(id);
    }

    public String getApplyDeptName(String applyId) {
        return this.baseMapper.getApplyDeptName(applyId);
    }
//
//	@Override
//	public AjaxResult upload(MultipartFile file) throws Exception {
//		try {
//			String fileType = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
//
//			InputStream inputStream = file.getInputStream();
//			Workbook workbook = null;
//
//			if (fileType.equals(".xls")) {
//				workbook = new HSSFWorkbook(inputStream);
//			} else if (fileType.equals(".xlsx")) {
//				workbook = new XSSFWorkbook(inputStream);
//			}
//
//			Sheet sheet = workbook.getSheetAt(0);
//			if (sheet == null) {
//				throw new Exception("导入的excel文件不存在,请确认excel的脚本是否为sheet0");
//			}
//
//			int rowSize = sheet.getPhysicalNumberOfRows();
//			if (rowSize == 0) {
//				throw new RuntimeException("对不起,该表没有数据");
//			}
//			if (rowSize == 1) {
//				throw new RuntimeException("对不起,该表只有标题");
//			}
//
//			List<List<String>> firstList = new ArrayList<>();
//			for (int i = 1; i < rowSize; i++) {
//				Row row = sheet.getRow(i);
//				List<String> secondList = new ArrayList<>();
//				for (int j = 0; j < 6; j++) { // 根据字段数量设置循环次数
//					Cell cell = row.getCell(j);
//					String value = "";
//					if (cell != null) {
//						if (cell.getCellType() == CellType.NUMERIC && org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(cell)) {
//							Date date = cell.getDateCellValue();
//							SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
//							if (date != null) {
//								value = dateFormat.format(date);
//							}
//						} else {
//							cell.setCellType(CellType.STRING);
//							String trim = cell.getStringCellValue().trim();
//							value = trim.replace(" ", "");
//						}
//
//					}
//					secondList.add(value);
//				}
//				firstList.add(secondList);
//			}
//
//			List<ShopCard> responseList = new ArrayList<>();
//			for (List<String> secondList : firstList) {
//                ShopCard response = new ShopCard();
//
//				responseList.add(panPunish);
//			}
//
//			this.saveBatch(responseList);
//
//			return AjaxResult.success("新增成功");
//
//		} catch (IOException e) {
//			e.printStackTrace();
//		}
//		return AjaxResult.success();
//	}

}
